/**
 * output package name
 */
package com.kingdee.eas.custom.basedata.client;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import org.apache.log4j.Logger;

import com.kingdee.bos.ui.face.CoreUIObject;
import com.kingdee.eas.custom.synchronizationDataFacadeFactory;
import com.kingdee.eas.util.client.MsgBox;

/**
 * output class name
 */
public class LodgingCostEditUI extends AbstractLodgingCostEditUI
{
    private static final Logger logger = CoreUIObject.getLogger(LodgingCostEditUI.class);
    
    @Override
    public void onLoad() throws Exception {
    	super.onLoad();
    	 
    	
 //   	 String a = this.oprtState; //ADDNEW  //VIEW  页面状态
     }
    
    @Override
    public void onShow() throws Exception {
    	super.onShow();  
   	 subsidy();

   	 
    	if ( this.oprtState.equals("ADDNEW")) {
    		
    		inlandForeign.setSelectedIndex(-1);
    		season.setSelectedIndex(-1);
    		dutyGrade.setSelectedIndex(-1);
    		  
    		this.editData.setString("inlandForeign",null); 
    		this.editData.setString("season",null); 
    		this.editData.setString("dutyGrade",null); 
		}
    	
    	this.inlandForeign.addActionListener(new ActionListener(){
			@Override
			public void actionPerformed(ActionEvent e) {
				subsidy();
			}		
    	});
    	this.season.addActionListener(new ActionListener(){
			@Override
			public void actionPerformed(ActionEvent e) {
				subsidy();
			}		
    	});
    }
    
    private void subsidy() {

    	if (inlandForeign.getSelectedItem() != null) {
	    	if (((com.kingdee.eas.custom.basedata.inlandForeign)inlandForeign.getSelectedItem()).getValue().equals("2")) {
	    		season.setEnabled(false);
	    		dutyGrade.setEnabled(false);
	    		season.setSelectedIndex(-1);
	    		dutyGrade.setSelectedIndex(-1);
	    		
	    		this.MonthOne.setEnabled(false);
	    		this.SunOne.setEnabled(false);
	    		this.MonthTow.setEnabled(false);
	    		this.SunTow.setEnabled(false);
	    		this.editData.setString("season",null); 
	    		this.editData.setString("dutyGrade",null); 
	    		dutyGrade.setSelectedIndex(-1);		 
	    		
	    		
	    		MonthOne.setSelectedIndex(-1);	
	    		SunOne.setSelectedIndex(-1);	
	    		MonthTow.setSelectedIndex(-1);	
	    		SunTow.setSelectedIndex(-1);	
	    		
	    		this.editData.setString("MonthOne",null); 
	    		this.editData.setString("SunOne",null); 
	    		this.editData.setString("MonthTow",null); 
	    		this.editData.setString("SunTow",null); 
	    	}else {
	    		this.MonthOne.setEnabled(true);
	    		this.SunOne.setEnabled(true);
	    		this.MonthTow.setEnabled(true);
	    		this.SunTow.setEnabled(true);
	    		
	    		dutyGrade.setEnabled(true);
	    		season.setEnabled(true);
			}
        }
    	
    	
    		
    	
	}
    
    
    @Override
    protected void verifyInput(ActionEvent e) throws Exception {

    	super.verifyInput(e);
    	if ( inlandForeign.getSelectedIndex() == -1) {
 		   MsgBox.showWarning("国内国外不能为空");
 		   abort();
 		}
    	
//    	if(inlandForeign.getSelectedIndex() != 1){
//	    	if (season.getSelectedIndex() == -1 ) {
//	 		   MsgBox.showWarning("季节不能为空");
//	 		   abort();
//	 		}
//    	}
    	if (inlandForeign.getSelectedItem() != null) {
	    	if (((com.kingdee.eas.custom.basedata.inlandForeign)inlandForeign.getSelectedItem()).getValue().equals("1")) {
    	
    	if (null == this.editData.get("MonthOne")) {
    		   MsgBox.showWarning("月份不能为空");
    		   abort();
    		}
     	if (null == this.editData.get("SunOne")) {
    		   MsgBox.showWarning("日期不能为空");
    		   abort();
    		}
     	if (null == this.editData.get("MonthTow")) {
    		   MsgBox.showWarning("月份不能为空");
    		   abort();
    		}
     	if (null == this.editData.get("SunTow")) {
    		   MsgBox.showWarning("日期不能为空");
    		   abort();
    		}
     	
     	int iMonthOne = Integer.parseInt(((com.kingdee.eas.mm.report.MonthEnum)MonthOne.getSelectedItem()).getValue().toString());
     	int iMonthTow = Integer.parseInt(((com.kingdee.eas.mm.report.MonthEnum)MonthTow.getSelectedItem()).getValue().toString());
     	
     	if(iMonthOne > iMonthTow){
     		MsgBox.showWarning("起始月份不能大于结束月份");
 		    abort();
    	}
     	String iSunOne = ((com.kingdee.eas.mm.report.Sun)SunOne.getSelectedItem()).getValue().toString();
     	String iSunTow = ((com.kingdee.eas.mm.report.Sun)SunTow.getSelectedItem()).getValue().toString();
     	int iSOne = Integer.parseInt(iSunOne);
     	int iSTow = Integer.parseInt(iSunTow);
     	
     	
     	if(iMonthOne == iMonthTow){
	     	if(iSOne > iSTow){
	     		MsgBox.showWarning("起始日期不能大于结束日期");
	 		    abort();
	    	}
     	}
	    	}
    	}
     	    	
     	
    	if (null == this.editData.get("city")) {
		   MsgBox.showWarning("城市名称不能为空");
		   abort();
		}
    	
    	if (null == this.editData.get("limit")) {
 		   MsgBox.showWarning("标准额度不能为空");
 		   abort();
 		}
    	if(inlandForeign.getSelectedIndex() != 1){
    	if (dutyGrade.getSelectedIndex() == -1) {
  		   MsgBox.showWarning("职务等级不能为空");
  		   abort();
  		}
    	}
    	if (null == this.editData.get("curren")) {
  		   MsgBox.showWarning("币种不能为空");
  		   abort();
  		}
    	
    	
    	
    }
    
    public void actionAddNew_actionPerformed(ActionEvent e) throws Exception
    {
        super.actionAddNew_actionPerformed(e);
        
        inlandForeign.setSelectedIndex(-1);
		season.setSelectedIndex(-1);
		dutyGrade.setSelectedIndex(-1);
		
		this.editData.setString("inlandForeign",null); 
		this.editData.setString("season",null); 
		this.editData.setString("dutyGrade",null); 
    }
    
    public void actionEdit_actionPerformed(ActionEvent e) throws Exception
    {
        super.actionEdit_actionPerformed(e);
        subsidy();
    }
	
    /**
     * output actionSubmit_actionPerformed
     */
    public void actionSubmit_actionPerformed(ActionEvent e) throws Exception
    {
    	super.actionSubmit_actionPerformed(e);
    	subsidy();
   
    }
    /**
     * output class constructor
     */
    public LodgingCostEditUI() throws Exception
    {
        super();
    }
    /**
     * output loadFields method
     */
    public void loadFields()
    {
        super.loadFields();
    }

    /**
     * output storeFields method
     */
    public void storeFields()
    {
        super.storeFields();
    }

    /**
     * output actionPageSetup_actionPerformed
     */
    public void actionPageSetup_actionPerformed(ActionEvent e) throws Exception
    {
        super.actionPageSetup_actionPerformed(e);
    }

    /**
     * output actionExitCurrent_actionPerformed
     */
    public void actionExitCurrent_actionPerformed(ActionEvent e) throws Exception
    {
        super.actionExitCurrent_actionPerformed(e);
    }

    /**
     * output actionHelp_actionPerformed
     */
    public void actionHelp_actionPerformed(ActionEvent e) throws Exception
    {
        super.actionHelp_actionPerformed(e);
    }

    /**
     * output actionAbout_actionPerformed
     */
    public void actionAbout_actionPerformed(ActionEvent e) throws Exception
    {
        super.actionAbout_actionPerformed(e);
    }

    /**
     * output actionOnLoad_actionPerformed
     */
    public void actionOnLoad_actionPerformed(ActionEvent e) throws Exception
    {
        super.actionOnLoad_actionPerformed(e);
    }

    /**
     * output actionSendMessage_actionPerformed
     */
    public void actionSendMessage_actionPerformed(ActionEvent e) throws Exception
    {
        super.actionSendMessage_actionPerformed(e);
    }

    /**
     * output actionCalculator_actionPerformed
     */
    public void actionCalculator_actionPerformed(ActionEvent e) throws Exception
    {
        super.actionCalculator_actionPerformed(e);
    }

    /**
     * output actionExport_actionPerformed
     */
    public void actionExport_actionPerformed(ActionEvent e) throws Exception
    {
        super.actionExport_actionPerformed(e);
    }

    /**
     * output actionExportSelected_actionPerformed
     */
    public void actionExportSelected_actionPerformed(ActionEvent e) throws Exception
    {
        super.actionExportSelected_actionPerformed(e);
    }

    /**
     * output actionRegProduct_actionPerformed
     */
    public void actionRegProduct_actionPerformed(ActionEvent e) throws Exception
    {
        super.actionRegProduct_actionPerformed(e);
    }

    /**
     * output actionPersonalSite_actionPerformed
     */
    public void actionPersonalSite_actionPerformed(ActionEvent e) throws Exception
    {
        super.actionPersonalSite_actionPerformed(e);
    }

    /**
     * output actionProcductVal_actionPerformed
     */
    public void actionProcductVal_actionPerformed(ActionEvent e) throws Exception
    {
        super.actionProcductVal_actionPerformed(e);
    }

    /**
     * output actionExportSave_actionPerformed
     */
    public void actionExportSave_actionPerformed(ActionEvent e) throws Exception
    {
        super.actionExportSave_actionPerformed(e);
    }

    /**
     * output actionExportSelectedSave_actionPerformed
     */
    public void actionExportSelectedSave_actionPerformed(ActionEvent e) throws Exception
    {
        super.actionExportSelectedSave_actionPerformed(e);
    }

    /**
     * output actionKnowStore_actionPerformed
     */
    public void actionKnowStore_actionPerformed(ActionEvent e) throws Exception
    {
        super.actionKnowStore_actionPerformed(e);
    }

    /**
     * output actionAnswer_actionPerformed
     */
    public void actionAnswer_actionPerformed(ActionEvent e) throws Exception
    {
        super.actionAnswer_actionPerformed(e);
    }

    /**
     * output actionRemoteAssist_actionPerformed
     */
    public void actionRemoteAssist_actionPerformed(ActionEvent e) throws Exception
    {
        super.actionRemoteAssist_actionPerformed(e);
    }

    /**
     * output actionPopupCopy_actionPerformed
     */
    public void actionPopupCopy_actionPerformed(ActionEvent e) throws Exception
    {
        super.actionPopupCopy_actionPerformed(e);
    }

    /**
     * output actionHTMLForMail_actionPerformed
     */
    public void actionHTMLForMail_actionPerformed(ActionEvent e) throws Exception
    {
        super.actionHTMLForMail_actionPerformed(e);
    }

    /**
     * output actionExcelForMail_actionPerformed
     */
    public void actionExcelForMail_actionPerformed(ActionEvent e) throws Exception
    {
        super.actionExcelForMail_actionPerformed(e);
    }

    /**
     * output actionHTMLForRpt_actionPerformed
     */
    public void actionHTMLForRpt_actionPerformed(ActionEvent e) throws Exception
    {
        super.actionHTMLForRpt_actionPerformed(e);
    }

    /**
     * output actionExcelForRpt_actionPerformed
     */
    public void actionExcelForRpt_actionPerformed(ActionEvent e) throws Exception
    {
        super.actionExcelForRpt_actionPerformed(e);
    }

    /**
     * output actionLinkForRpt_actionPerformed
     */
    public void actionLinkForRpt_actionPerformed(ActionEvent e) throws Exception
    {
        super.actionLinkForRpt_actionPerformed(e);
    }

    /**
     * output actionPopupPaste_actionPerformed
     */
    public void actionPopupPaste_actionPerformed(ActionEvent e) throws Exception
    {
        super.actionPopupPaste_actionPerformed(e);
    }

    /**
     * output actionToolBarCustom_actionPerformed
     */
    public void actionToolBarCustom_actionPerformed(ActionEvent e) throws Exception
    {
        super.actionToolBarCustom_actionPerformed(e);
    }

    /**
     * output actionCloudFeed_actionPerformed
     */
    public void actionCloudFeed_actionPerformed(ActionEvent e) throws Exception
    {
        super.actionCloudFeed_actionPerformed(e);
    }

    /**
     * output actionCloudShare_actionPerformed
     */
    public void actionCloudShare_actionPerformed(ActionEvent e) throws Exception
    {
        super.actionCloudShare_actionPerformed(e);
    }

    /**
     * output actionCloudScreen_actionPerformed
     */
    public void actionCloudScreen_actionPerformed(ActionEvent e) throws Exception
    {
        super.actionCloudScreen_actionPerformed(e);
    }

    /**
     * output actionXunTongFeed_actionPerformed
     */
    public void actionXunTongFeed_actionPerformed(ActionEvent e) throws Exception
    {
        super.actionXunTongFeed_actionPerformed(e);
    }

    /**
     * output actionSave_actionPerformed
     */
    public void actionSave_actionPerformed(ActionEvent e) throws Exception
    {
        super.actionSave_actionPerformed(e);
    }


    /**
     * output actionCancel_actionPerformed
     */
    public void actionCancel_actionPerformed(ActionEvent e) throws Exception
    {
        super.actionCancel_actionPerformed(e);
    }

    /**
     * output actionCancelCancel_actionPerformed
     */
    public void actionCancelCancel_actionPerformed(ActionEvent e) throws Exception
    {
        super.actionCancelCancel_actionPerformed(e);
    }

    /**
     * output actionFirst_actionPerformed
     */
    public void actionFirst_actionPerformed(ActionEvent e) throws Exception
    {
        super.actionFirst_actionPerformed(e);
    }

    /**
     * output actionPre_actionPerformed
     */
    public void actionPre_actionPerformed(ActionEvent e) throws Exception
    {
        super.actionPre_actionPerformed(e);
    }

    /**
     * output actionNext_actionPerformed
     */
    public void actionNext_actionPerformed(ActionEvent e) throws Exception
    {
        super.actionNext_actionPerformed(e);
    }

    /**
     * output actionLast_actionPerformed
     */
    public void actionLast_actionPerformed(ActionEvent e) throws Exception
    {
        super.actionLast_actionPerformed(e);
    }

    /**
     * output actionPrint_actionPerformed
     */
    public void actionPrint_actionPerformed(ActionEvent e) throws Exception
    {
        super.actionPrint_actionPerformed(e);
    }

    /**
     * output actionPrintPreview_actionPerformed
     */
    public void actionPrintPreview_actionPerformed(ActionEvent e) throws Exception
    {
        super.actionPrintPreview_actionPerformed(e);
    }

    /**
     * output actionCopy_actionPerformed
     */
    public void actionCopy_actionPerformed(ActionEvent e) throws Exception
    {
        super.actionCopy_actionPerformed(e);
    }

    /**
     * output actionAddNew_actionPerformed
     */
    

 
    /**
     * output actionRemove_actionPerformed
     */
    public void actionRemove_actionPerformed(ActionEvent e) throws Exception
    {
        super.actionRemove_actionPerformed(e);
    }

    /**
     * output actionAttachment_actionPerformed
     */
    public void actionAttachment_actionPerformed(ActionEvent e) throws Exception
    {
        super.actionAttachment_actionPerformed(e);
    }

    /**
     * output actionSubmitOption_actionPerformed
     */
    public void actionSubmitOption_actionPerformed(ActionEvent e) throws Exception
    {
        super.actionSubmitOption_actionPerformed(e);
    }

    /**
     * output actionReset_actionPerformed
     */
    public void actionReset_actionPerformed(ActionEvent e) throws Exception
    {
        super.actionReset_actionPerformed(e);
    }

    /**
     * output actionMsgFormat_actionPerformed
     */
    public void actionMsgFormat_actionPerformed(ActionEvent e) throws Exception
    {
        super.actionMsgFormat_actionPerformed(e);
    }

    /**
     * output getBizInterface method
     */
    protected com.kingdee.eas.framework.ICoreBase getBizInterface() throws Exception
    {
        return com.kingdee.eas.custom.basedata.LodgingCostFactory.getRemoteInstance();
    }

    /**
     * output createNewData method
     */
    protected com.kingdee.bos.dao.IObjectValue createNewData()
    {
        com.kingdee.eas.custom.basedata.LodgingCostInfo objectValue = new com.kingdee.eas.custom.basedata.LodgingCostInfo();
        objectValue.setCreator((com.kingdee.eas.base.permission.UserInfo)(com.kingdee.eas.common.client.SysContext.getSysContext().getCurrentUser()));
		
        return objectValue;
    }

}